def func():
    result = 0
    def inner(num):
        nonlocal result
        result += num
        print(result)
    return  inner

fn = func()
fn(1)
fn(2)
fn(3)